package com.mybatis.demo.pojo;

import com.google.common.collect.Lists;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import javax.annotation.Resource;
import java.io.InputStream;
import java.sql.DriverManager;
import java.util.List;

/**
 * @Author: 朱胜伟
 * @CreateTime: 2020-12-31 15:51
 * @Description:
 */
public class MybatisTest1 {
    public static void main(String[] args) throws Exception{
        List<User> s = Lists.newArrayList();
        Class.forName("com.mysql.jdbc.Driver");
//        DriverManager.getConnection("");
        String resource = "mybatis-config.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        SqlSession session = sqlSessionFactory.openSession();
        User user = session.selectOne("user.findUserById",1);
        System.out.println(user);
    }
}
